package com.cmc.cloud.cmclink.doc.util.so;

/**
 * 比较测试
 *
 * @author 陈正
 * @date 2025/08/14 14:42
 **/
public class TestCompareUtils {

    public static void main(String[] args) {
        // 自定义比较器
        CompareUtils<Person> personComparator = new CompareUtils<Person>();
        personComparator.comparingField(Person::getTitle).thenComparing(Person::getAge).thenComparing(Person::getTitle);
        Person p1 = new Person("Jane", 25, "120Q");
        Person p2 = new Person("Jane", 25, "123");
        System.out.println(CompareUtils.compareByFields(p1, p2, personComparator));
    }
}

class Son {
    private String title;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}

class Person extends Son {
    private String name;
    private Integer age;

    public Person(String name, Integer age, String title) {
        this.name = name;
        this.age = age;
        super.setTitle(title);
    }

    public String getName() {
        return name;
    }

    public Integer getAge() {
        return age;
    }
}
